import request from '@/utils/request';

/**
 * 分页查询订单运费
 */
export async function pageContainerBillFees(params) {
  const res = await request.get('/order/containerBillFee/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询订单运费列表
 */
export async function listContainerBillFees(params) {
  const res = await request.get('/order/containerBillFee', {
    params
  });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询订单运费
 */
export async function getContainerBillFee(id) {
  const res = await request.get('/order/containerBillFee/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加订单运费
 */
export async function addContainerBillFee(data) {
  const res = await request.post('/order/containerBillFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改订单运费
 */
export async function updateContainerBillFee(data) {
  const res = await request.put('/order/containerBillFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除订单运费
 */
export async function removeContainerBillFee(id) {
  const res = await request.delete('/order/containerBillFee/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
